<template>
  <div class="box">
    <div class="clearfix top">
      <p class="title">男女比例</p>
      <p class="bg"></p>
    </div>

    <div class="sex">
      <div class="man">
        <img src="../../images/man.png" />
      </div>
      <div class="woman">
        <img src="../../images/woman.png" />
      </div>
    </div>

    <div class="rate">
      <p>男士58%</p>
      <p>女士42%</p>
    </div>
    <div class="charts" ref="echartsRef"></div>
  </div>
</template>

<script setup lang="ts">
import { ref, onMounted } from 'vue'

import * as echarts from 'echarts'
const echartsRef = ref()
onMounted(() => {
  const myCharts = echarts.init(echartsRef.value)
  myCharts.setOption({
    title: {
      text: '男女比例',
      textStyle: {
        color: 'skyblue'
      },
      left: '50%'
    },
    grid: {
      left: 0,
      top: 0,
      right: 0,
      bottom: 0
    },
    xAxis: {
      show: false,
      min: 0,
      max: 100
    },
    yAxis: {
      show: false,
      type: 'category'
    },
    series: [
      {
        type: 'bar',
        data: [58],
        barWidth: 20,
        z: 3,
        itemStyle: {
          color: '#007afe',
          borderRadius: 20
        }
      },
      {
        type: 'bar',
        data: [100],
        barWidth: 20,
        barGap: '-100%',
        itemStyle: {
          color: '#ff4b7a',
          borderRadius: 20
        }
      }
    ]
  })
})
</script>

<style scoped lang="scss">
.box {
  display: flex;
  flex-direction: column;
  background: #fff;
  background: url(../../images/dataScreen-main-cb.png) no-repeat;
  background-size: 100% 100%;
  overflow: hidden;
  .top {
    padding-top: 10px;
    font-size: 20px;
    margin: 0 20px;
    color: #fff;
    .title {
    }
    .bg {
      margin-top: 10px;
      width: 68px;
      height: 7px;
      background: url(../../images/dataScreen-title.png) no-repeat;
      background-size: 100% 100%;
    }
  }

  .sex {
    display: flex;
    justify-content: center;
    .man {
      margin: 20px;
      display: flex;
      justify-content: center;
      align-items: center;
      width: 111px;
      height: 115px;
      background: url(../../images/man-bg.png) no-repeat;
    }
    .woman {
      margin: 20px;
      display: flex;
      justify-content: center;
      align-items: center;
      width: 111px;
      height: 115px;
      background: url(../../images/woman-bg.png) no-repeat;
    }
  }
  .rate {
    display: flex;
    justify-content: space-between;
    align-items: center;
  }

  .charts {
    width: 100%;
    flex: 1;
  }
}
</style>
